-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIT ARM64-SVE: Add Sve.CreateFalseMask*() #102076
Conversation
Also added tests for Sve.CreateTrueMask*()
Note regarding the
|
Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics |
@kunalspathak @dotnet/arm64-contrib @a74nh |
@@ -665,6 +665,96 @@ public new abstract class Arm64 : AdvSimd.Arm64 | |||
public static unsafe ulong Count8BitElements([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) => Count8BitElements(pattern); | |||
|
|||
|
|||
/// CreateFalseMaskByte : Set all predicate elements to false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ///
is the XML documentation comment prefix and so needs to follow the standard doc comment prefix, being in the <summary>
region if it's present.
It looks like this ended up being missed in past reviews, but it may cause problems with the downstream tools and will likely require the documentation team to do more work if it's not fixed.
We should only need the Set all predicate elements to false
part of the text since the method name is implicit from the member the comment is attached to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this ended up being missed in past reviews
good catch. will fix it for other docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So should I change it to the following? If not, please provide an example based on this comment.
// Set all predicate elements to false
/// <summary>
/// svbool_t svpfalse[_b]()
/// PFALSE Presult.B
/// </summary>
public static unsafe Vector<byte> CreateFalseMaskByte() => CreateFalseMaskByte();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that looks right
(I'd prefer to keep the CreateFalseMaskByte
, because then it's explicit what the comment attaches to, but let's keep with convention)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be ///
instead of //
and that basically is representing the logical group name of APIs that follows the comments.
- // Set all predicate elements to false
+ /// Set all predicate elements to false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, please check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM minus the XML doc comment fix that's needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes looks good. Added some comments around test.
@@ -0,0 +1,117 @@ | |||
// Licensed to the .NET Foundation under one or more agreements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not named as SveCreateFalseMaskTest.template
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you planning to reuse it for other APIs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was my suggestion - I'd hope we can use this one for future APIs. Whereas the SveCreateTrueMaskTest.template
is specific to true mask due to the handling.
@@ -3009,6 +3009,27 @@ | |||
("SveVecBinOpTest.template", new Dictionary<string, string> { ["TestName"] = "Sve_Divide_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Divide", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Divide(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Divide(left[i], right[i])"}), | |||
("SveVecBinOpTest.template", new Dictionary<string, string> { ["TestName"] = "Sve_Divide_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Divide", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Divide(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Divide(left[i], right[i])"}), | |||
|
|||
("SveSimpleNoOpTest.template", new Dictionary<string, string> { ["TestName"] = "Sve_CreateFalseMaskByte_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "CreateFalseMaskByte", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["LargestVectorSize"] = "8", ["ValidateIterResult"] = "result[i] != 0",}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
["LargestVectorSize"] = "64"
for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it's not used by SveSimpleNoOpTest.template
and can be safely removed along with an according line in the test template. Sounds good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, please check.
throw new Exception("Incorrect esize"); | ||
} | ||
|
||
int elements = (int)(Sve.Count64BitElements()) * 64 / esize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
int elements = (int)(Sve.Count64BitElements()) * 64 / esize; | |
int elements = (int)(Sve.Count8BitElements() / esize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would have to be int elements = (int)(Sve.Count8BitElements()) * 8 / esize;
anyway I suppose? Or do you suggest to make esize
denote the size of elements in bytes as well? At the moment it's in bits, not bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, should have * 8
and that gives better readability in terms of "X bytes".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test.RunBasicScenario_CreateFalseMask(); | ||
|
||
// Validates calling via reflection works | ||
// TODO-SVE: Enable once register allocation exists for predicates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@a74nh - can you remind me why this doesn't work without predicate register support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this from another template without giving it a critical look. Will be happy to remove if @a74nh confirms that the comment isn't required here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I enabled this test for SveLoadVector_int
and ran it. It passed. Not sure what the issues was now - was possibly due to missing mask handling (not predicates).
@mikabl-arm - could you uncomment this and remove the TODO, it should work.
We should re-enable all the others in a future PR.
|
||
// DecodePredCount() | ||
// ================= | ||
// integer DecodePredCount(bits(5) bitpattern, integer esize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if we can have the "copy-pasted" code of this from Arm manual in dotnet codebase because of copyrights. can we simplify the summary docs of DecodePredCount
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
// bits(PL) result; | ||
// constant integer psize = esize DIV 8; | ||
// | ||
// for e = 0 to elements-1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here. Please simplify and write the description in text of what we are trying to accomplish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Can you also please run the stress test on these? For more details on how to run them, please refer the notes at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
@@ -665,6 +665,96 @@ public new abstract class Arm64 : AdvSimd.Arm64 | |||
public static unsafe ulong Count8BitElements([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) => Count8BitElements(pattern); | |||
|
|||
|
|||
/// Set all predicate elements to false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This should really be written just once, just as we do for e.g. in /// BitwiseClear : Bitwise clear
or /// BooleanNot : Logically invert boolean condition
. Same applies for CreateTrue*
APIs. @mikabl-arm - do you mind fixing it in your next PR please?
@@ -608,6 +608,96 @@ public new abstract class Arm64 : AdvSimd.Arm64 | |||
public static unsafe ulong Count8BitElements([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw new PlatformNotSupportedException(); } | |||
|
|||
|
|||
/// Set all predicate elements to false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
* JIT ARM64-SVE: Add Sve.CreateFalseMask*() Also added tests for Sve.CreateTrueMask*() * Remove code copied from the Arm manual. * Remove LargestVectorSize from CreateFalseMask* template parameters * Fix documentation comments for CreateFalseMask*() * Improve code readability by operating byte-sized elements. * Enable reflection scenario tests
Also added tests for Sve.CreateTrueMask*()
Tests results: